use AppleShop
go
--1.Admin Login Procedure

create procedure spAdminLog
@user varchar(10)
as	
	begin
	select * from Admins where AdminId = @user
	end
	
go

exec spAdminLog 'admin'

go

insert into Product(ProductsID, ProductsName, ProductsTypeName, ProductsPrice, ProductsImage) 
			values('AppleTV','AppleTV','Apple TV',99,'~/IMG/AppleTV/AppleTV.png')

update Product
set ProductsImage = '~/IMG/AppleTV/AppleTV.png'
where ProductsID = 'AppleTV'

go

insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('AppleTV','~/IMG/AppleTV/AppleTV-Details-1.png','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('AppleTV','~/IMG/AppleTV/AppleTV-Details-2.png','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('AppleTV','~/IMG/AppleTV/AppleTV-Details-3.png','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('AppleTV','~/IMG/AppleTV/AppleTV-Details-4.png','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('AppleTV','~/IMG/AppleTV/AppleTV-Details-5.png','...')
insert into ProductDetails(DetailsID, DetailsImage, DetailsText) values('AppleTV','~/IMG/AppleTV/AppleTV-Details-6.png','...')

go

--2.Create store procedure Product

create procedure spGetAppleTV
as
	begin
		select * from Product where ProductsID like '%AppleTV%' and ProductsIsDel = 1
	end
go

create procedure spGetProductAppleTVDetails
@ID varchar(50)
as
	begin
		select * from ProductDetails where DetailsID = @ID
	end
go	

exec spGetProductAppleTVDetails 'AppleTV'

go

create procedure spGetAllProductAppleTVDetails
as
	begin
		select * from ProductDetails where DetailsID = 'AppleTV'
	end
	
go

create procedure spGetProductAppleTVDetailsByNo
@No int
as
	begin
		select * from ProductDetails where DetailsNo = @No
	end
	
go

create procedure spUpdateProductAppleTVDetails
@No int,
@Image varchar(200)
as
	begin
		Update ProductDetails SET DetailsImage = @Image Where DetailsNo = @No
	end
	
go

create procedure spInsertNewAppleTVDetails
@Image varchar(200)
as
	begin
		insert into ProductDetails(DetailsID, DetailsImage, DetailsText) 
		values ('AppleTV', @Image, '....')
	end
	
go

create procedure spDeleteAppleTV
@No int
as
	begin
		Delete From ProductDetails Where DetailsNo = @No
	end